package com.dt.platform.generator.module.hr;


import com.dt.platform.constants.db.HrTables;
import com.dt.platform.constants.enums.hr.PersonBillStatusEnum;
import com.dt.platform.domain.hr.Person;
import com.dt.platform.domain.hr.meta.PersonMeta;
import com.dt.platform.domain.hr.meta.PersonRetireActMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.proxy.hr.PersonServiceProxy;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;


public class ActPersonRetireGtr extends BaseCodeGenerator {
    public ActPersonRetireGtr() {
        super(HrTables.HR_PERSON_RETIRE_ACT.$TABLE,"666943320815042560");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.ID).basic().hidden(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.CONTENT).search().fuzzySearch();

        cfg.getPoClassFile().addSimpleProperty(Person.class,"person","person","person");
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"oper","oper","oper");
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"handover","handover","handover");

        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.RETIRE_DATE).form().validate().required().form().dateInput().format("yyyy-MM-dd").search().range();
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.RETIRE_DATE).search().range();
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.OPER_TIME).form().dateInput().format("yyyy-MM-dd").search().range();
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.OPER_TIME).search().range();


        cfg.view().search().inputLayout(
                new Object[]{
                        HrTables.HR_PERSON_RETIRE_ACT.STATUS,
                        HrTables.HR_PERSON_RETIRE_ACT.PERSON_ID,
                        HrTables.HR_PERSON_RETIRE_ACT.HANDOVER_ID,
                        HrTables.HR_PERSON_RETIRE_ACT.OPER_USER_ID,
                },
                new Object[]{
                        HrTables.HR_PERSON_RETIRE_ACT.RETIRE_DATE,
                        HrTables.HR_PERSON_RETIRE_ACT.OPER_TIME,
                }
        );

        cfg.view().list().disableBatchDelete();


        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.FILE_IDS).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.UPDATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.UPDATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.CREATE_BY).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.CREATE_TIME).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_TRANSFER_ACT.NOTE).form().table().disable(true);


        cfg.view().field(HrTables.HR_PERSON_TRANSFER_ACT.STATUS).form()
                .label("办理状态").selectBox().enumType(PersonBillStatusEnum.class);


        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.OPER_USER_ID).table().fillBy("oper","name");
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.OPER_USER_ID).form().readOnly().form()
                .button().chooseEmployee(true);


        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.PERSON_ID).form().validate().required().form().selectBox()
                .queryApi(PersonServiceProxy.QUERY_PAGED_LIST)
                .paging(true).filter(true).toolbar(false)
                .valueField(PersonMeta.ID).
                textField(PersonMeta.NAME).
                fillWith(PersonRetireActMeta.PERSON).muliti(false);

        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.HANDOVER_ID).table().fillBy("handover","name");
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.HANDOVER_ID).form()
                .button().chooseEmployee(true);



        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.FILE_IDS).form().table().disable(true);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.FILE_IDS).form().upload().maxFileCount(3).acceptAllType();
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.CONTENT).form().validate().required().form().textArea().height(80);
        cfg.view().field(HrTables.HR_PERSON_RETIRE_ACT.NOTE).form().textArea().height(80);





        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);



        cfg.view().search().rowsDisplay(1);
        cfg.view().formWindow().width("80%");;
        cfg.view().formWindow().bottomSpace(100);
        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_PERSON_RETIRE_ACT.PERSON_ID,
                        HrTables.HR_PERSON_RETIRE_ACT.RETIRE_DATE,
                },
                new Object[] {
                        HrTables.HR_PERSON_RETIRE_ACT.HANDOVER_ID,
                        HrTables.HR_PERSON_RETIRE_ACT.OPER_USER_ID,
                }
        );

        cfg.view().form().addGroup(null,
                new Object[] {
                        HrTables.HR_PERSON_RETIRE_ACT.CONTENT,
                        HrTables.HR_PERSON_RETIRE_ACT.NOTE,
                        HrTables.HR_PERSON_RETIRE_ACT.FILE_IDS,
                }
        );

        cfg.view().list().operationColumn().addActionButton("确认","confirmData","confirm-data-button");
        cfg.view().list().addJsVariable("CUR_EMP_ID","[[${curEmpId}]]","curEmpId");
        cfg.view().form().addJsVariable("CUR_EMP_ID","[[${curEmpId}]]","curEmpId");
        cfg.view().form().addJsVariable("CUR_USER_NAME","[[${curUserName}]]","curUserName");

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setBpmEventAdaptor(WriteMode.COVER_EXISTS_FILE)
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE) //列表HTML页
                .setExtendJsFile(WriteMode.IGNORE);
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        ActPersonRetireGtr g=new ActPersonRetireGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
       // System.out.println("############"+g.getTablePrefix());
       // g.removeByBatchId("801716675761143808");
      //  //生成菜单
     //  g.generateMenu(PersonRetireActServiceProxy.class, PersonRetireActPageController.class);
    }
}
